import 'package:flutter/material.dart';
import 'package:flutterapp/page/utils/scopoed_model_helper.dart';
import 'package:flutterapp/scoped_model/auth.dart';

import 'index_my_data.dart';

class MyMainWidget extends StatelessWidget {
  final FunctionButtonItem data;

  const MyMainWidget(
    this.data, {
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        if ('房屋管理' == data.title) {
          //data.onTapHandle(context);
          bool isLogin =
              ScopedModelHelper.getModel<AuthModel>(context).isLogin; //todo
          print('------------------------------------------');
          print(isLogin);
          print('------------------------------------------');
          //判断是否登录
          if (isLogin) {
            Navigator.pushNamed(context, 'roomManage');
            return;
          }

          Navigator.pushNamed(context, 'login');
          // Navigator.pushNamed(context, 'roomManage');
        }
      },
      child: Container(
        width: MediaQuery.of(context).size.width * 0.3,
        margin: EdgeInsets.only(top: 15.0),
        padding: EdgeInsets.only(left: 23.0),
        child: Column(
          //mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            Image.network(data.imageUri, width: 50.0),
            Padding(
              padding: EdgeInsets.only(top: 8.0),
            ),
            Text(data.title,
                style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w500)),
          ],
        ),
      ),
    );
  }
}
